package com.regal.reg;

import javax.swing.*;
import javax.swing.text.*;

//licc.0606
public class JNumberField extends JTextField{
        public JNumberField(int cols) {
                super(cols);
        }
        public JNumberField() {
                super();
        }

        protected Document createDefaultModel() {
                return new NumberDocument();
        }

        static class NumberDocument extends PlainDocument {

                public void insertString(int offs, String str, AttributeSet a) throws BadLocationException {

                        if (str == null) {
                                return;
                        }
                        String newString="";
                        char[] upper = str.toCharArray();
                        for (int i = 0; i < upper.length; i++) {
                                if(upper[i]>='0'&&upper[i]<='9')
                                        newString+=upper[i];
                        }
                        super.insertString(offs, newString, a);
                }
        }
}
